﻿using System.Configuration;
using System.Data.SqlClient;
using System.Web;

namespace DAL.Common
{
    public class MyConnection
    {
        public static SqlConnection Current
        {
            get
            {
                if (!HttpContext.Current.Items.Contains("myConnection"))
                {
                    string connectionString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
                    var connection = new SqlConnection(connectionString);
                    connection.Open();
                    HttpContext.Current.Items.Add("myConnection", connection);
                }
                return HttpContext.Current.Items["myConnection"] as SqlConnection;
            }
        }
    }
}